﻿using EasyTest.Shared.EnumType;
using EasyTest.Shared.TestAttribute;
using EasyTest.Shared.外部访问;
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;


namespace ZLGCANoptimize
{
    public class 版本信息
    {
        //static ZLGCANHelper zLGCANHelper = null;
        //static List<ZCAN_Receive_Data> zCAN_Receive_Datas = null;

#if ELO20240927
        [ExposedMethodAttribute("")]
        public bool 读DSP软件版本号BE32(int 通道, out string DSP软件版本号, out int 字节长度, out string 信息)
        {
            DSP软件版本号 = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 BE 32 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(100);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    DSP软件版本号 = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[8];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                /*
                    10 0D 62 BE 32 44 02 00
                    21 02 44 24 06 01 00 00
                */
                //44是ASCII码，02 00 02是十进制，44是ASCII码，最后三个是BCD码
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 5) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    DSP软件版本号 = 信息;
                    return false;
                }
                信息 = string.Join(",", datas);

                //StringBuilder sb = new StringBuilder();
                //sb.Append($"{Char.ConvertFromUtf32(Convert.ToInt32(hexValues[0], 16))}");
                //sb.Append($"{Char.ConvertFromUtf32(Convert.ToInt32(hexValues[4], 16))}");
                //DSP软件版本号 = sb.ToString();
                hexValues[0] = HexToAsciiExtended(hexValues[0]);
                //hexValues[1] = HexStringsToDecimalStrings(hexValues[1]);
                //hexValues[2] = HexStringsToDecimalStrings(hexValues[2]);
                //hexValues[3] = HexStringsToDecimalStrings(hexValues[3]);
                hexValues[4] = HexToAsciiExtended(hexValues[4]);
                DSP软件版本号 = String.Join("", hexValues);

                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读MCUSDK软件版本号(int 通道, out string SDK软件版本号, out int 字节长度, out string 信息)
        {
            SDK软件版本号 = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    SDK软件版本号 = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 300, 100.0);
                bool 发送结果A = false;
                bool 发送结果B = false;
                for (int i = 0; i < 3; i++)
                {
                    发送结果A = zLGCANHelper.SentData(通道, 1889U, "03 22 B0 11 00 00 00 00", true, SendType.正常发送, Protocol.CAN, Frametype.标准帧, 1);
                    Thread.Sleep(60);
                    发送结果B = zLGCANHelper.SentData(通道, 1889U, "30 08 14 00 00 00 00 00", true, SendType.正常发送, Protocol.CAN, Frametype.标准帧, 1);
                    if (发送结果A && 发送结果B)
                    {
                        break;
                    }
                }
                if (!发送结果A || !发送结果B)
                {
                    信息 = "发送失败...";
                    SDK软件版本号 = 信息;
                    return false;
                }

                zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 3, 1500.0);
                string[] data = ZLGCanTool.GetData(zCAN_Receive_Datas);
                string[] array = new string[8];
                int num = 0;
                bool OK10 = false;
                bool OK21 = false;
                foreach (string text in data)
                {
                    if (text.Trim().StartsWith("10"))
                    {
                        OK10 = true;
                        for (int k = 0; k < text.Split(new char[] { ' ' }).Length; k++)
                        {
                            bool flag10 = k < 5 || k > 7;
                            if (!flag10)
                            {
                                array[num] = text.Split(new char[] { ' ' })[k];
                                num++;
                            }
                        }
                    }
                    else
                    {
                        if (text.Trim().StartsWith("21"))
                        {
                            OK21 = true;
                            for (int l = 0; l < text.Split(new char[] { ' ' }).Length; l++)
                            {
                                bool flag12 = l == 0 || l > 5;
                                if (!flag12)
                                {
                                    array[num] = text.Split(new char[] { ' ' })[l];
                                    num++;
                                }
                            }
                        }
                    }
                }
                if (!OK10 || !OK21)
                {
                    信息 = string.Join("", data);
                    SDK软件版本号 = 信息;
                    return false;
                }

                字节长度 = array.Length;
                array[0] = HexToAsciiExtended(array[0]);
                array[4] = HexToAsciiExtended(array[4]);
                信息 = string.Join(",", data);
                SDK软件版本号 = String.Join("", array);
                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                SDK软件版本号 = 信息;
            }
            return false;
        }
#else
        [ExposedMethodAttribute("")]
        public bool 读DSP软件版本号BE32(int 通道, out string DSP软件版本号, out int 字节, out string 信息)
        {
            DSP软件版本号 = "";
            字节 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 BE 32 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    DSP软件版本号 = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[8];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                /*
                    10 0D 62 BE 32 44 02 00
                    21 02 44 24 06 01 00 00
                */
                //44是ASCII码，02 00 02是十进制，44是ASCII码，最后三个是BCD码
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 5) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节 = hexValues.Length;
                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    DSP软件版本号 = 信息;
                    return false;
                }
                信息 = string.Join(",", datas);

                StringBuilder sb = new StringBuilder();
                sb.Append($"{Char.ConvertFromUtf32(Convert.ToInt32(hexValues[0], 16))}");
                sb.Append($"{Convert.ToInt32(hexValues[1], 16)}");
                sb.Append($"{Convert.ToInt32(hexValues[2], 16)}");
                sb.Append($"{Convert.ToInt32(hexValues[3], 16)}");
                sb.Append($"{Char.ConvertFromUtf32(Convert.ToInt32(hexValues[4], 16))}");
                sb.Append($"{string.Join("", hexValues.Skip(5).Take(3))}");
                DSP软件版本号 = sb.ToString();
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读MCUSDK软件版本号(int 通道, out string SDK软件版本号, out int 字节, out string 信息)
        {
            SDK软件版本号 = "";
            字节 = 0;
            信息 = "";
            bool flag2;
            try
            {
                bool flag = !数据.初始化(通道, out ZLGCANHelper zLGCANHelper);
                if (flag)
                {
                    信息 = "启动can设备失败";
                    SDK软件版本号 = 信息;
                    flag2 = false;
                }
                else
                {
                    List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 300, 100.0);
                    bool flag3 = false;
                    bool flag4 = false;
                    for (int i = 0; i < 3; i++)
                    {
                        flag3 = zLGCANHelper.SentData(通道, 1889U, "03 22 B0 11 00 00 00 00", true, SendType.正常发送, Protocol.CAN, Frametype.标准帧, 1);
                        Thread.Sleep(60);
                        flag4 = zLGCANHelper.SentData(通道, 1889U, "30 08 14 00 00 00 00 00", true, SendType.正常发送, Protocol.CAN, Frametype.标准帧, 1);
                        bool flag5 = flag3 && flag4;
                        if (flag5)
                        {
                            break;
                        }
                    }
                    bool flag6 = !flag3 || !flag4;
                    if (flag6)
                    {
                        信息 = "发送失败...";
                        SDK软件版本号 = 信息;
                        flag2 = false;
                    }
                    else
                    {
                        zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 3, 1500.0);
                        string[] data = ZLGCanTool.GetData(zCAN_Receive_Datas);
                        string[] array = new string[5];
                        int num = 0;
                        bool flag7 = false;
                        bool flag8 = false;
                        foreach (string text in data)
                        {
                            bool flag9 = text.Trim().StartsWith("10");
                            if (flag9)
                            {
                                flag7 = true;
                                for (int k = 0; k < text.Split(new char[] { ' ' }).Length; k++)
                                {
                                    bool flag10 = k < 5 || k > 7;
                                    if (!flag10)
                                    {
                                        array[num] = text.Split(new char[] { ' ' })[k];
                                        num++;
                                    }
                                }
                            }
                            else
                            {
                                bool flag11 = text.Trim().StartsWith("21");
                                if (flag11)
                                {
                                    flag8 = true;
                                    for (int l = 0; l < text.Split(new char[] { ' ' }).Length; l++)
                                    {
                                        bool flag12 = l == 0 || l > 2;
                                        if (!flag12)
                                        {
                                            array[num] = text.Split(new char[] { ' ' })[l];
                                            num++;
                                        }
                                    }
                                }
                            }
                        }
                        string text2 = "";
                        bool flag13 = !flag7 || !flag8;
                        if (flag13)
                        {
                            信息 = string.Join("", data);
                            SDK软件版本号 = 信息;
                            flag2 = false;
                        }
                        else
                        {
                            字节 = array.Length;
                            foreach (string text3 in array)
                            {
                                int num2 = Convert.ToInt32(text3, 16);
                                string text4 = char.ConvertFromUtf32(num2);
                                text2 += text4;
                            }
                            信息 = string.Join(",", data);
                            SDK软件版本号 = string.Join("", array.ToList<string>().GetRange(0, 4)).Trim() + "/" + array[4];
                            flag2 = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                SDK软件版本号 = 信息;
                flag2 = false;
            }
            return flag2;
        }
#endif

        [ExposedMethodAttribute("")]
        public bool 读取SN_F18C(int 通道, out string SN, out int SN字节长度, out string 信息)
        {
            信息 = "";
            SN = "";
            SN字节长度 = SN.Length;
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 1000, 100);
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = new List<ZCAN_Receive_Data>();
                SN = CanFactory.GetSN(通道, zLGCANHelper, zCAN_Receive_Datas, out 信息).Trim();
                if (SN == null)
                    return false;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                SN = "";
                return false;
            }
            SN字节长度 = SN.Trim().Length;
            return true;
        }
        [ExposedMethodAttribute("")]
        public bool ECU应用软件(int 通道, out string ECU应用软件, out int 字节长度, out string 信息, int ECU应用软件号 = 2)
        {
            信息 = "";
            ECU应用软件 = "";
            字节长度 = ECU应用软件.Length;
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    ECU应用软件 = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                ECU应用软件 = CanFactory.获取ECU应用软件(通道, (ECU应用软件Enum)ECU应用软件号, zLGCANHelper, zCAN_Receive_Datas, out 信息).Trim();
                if (ECU应用软件 == null)
                    return false;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                ECU应用软件 = 信息;
                return false;
            }
            字节长度 = ECU应用软件.Length;
            return true;
        }
        [ExposedMethodAttribute("")]
        public bool 硬件版本号(int 通道, out string 硬件版本号, out int 字节长度, out string 信息)
        {
            硬件版本号 = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 3; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 87 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(60);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    硬件版本号 = 信息;
                    return false;
                }
                zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);
                string[] hexValues = new string[5];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    else if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i == 0 || i > 2) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                var hexValuesStr = "";
                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    硬件版本号 = 信息;
                    return false;
                }


                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValuesStr += stringValue;
                }
                信息 = string.Join(",", datas);
                硬件版本号 = String.Join("", hexValues.ToList().GetRange(0, 4)).Trim() + "/" + hexValues[4];
                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                硬件版本号 = 信息;
                return false;
            }
            return true;
        }
        [ExposedMethodAttribute("")]
        public bool 读取ECU零件号(int 通道, out string ECU零件号, out int 字节长度, out string 信息)
        {
            ECU零件号 = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 300, 100);//清空缓存
                bool r1 = false, r2 = false;
                for (int i = 0; i < 3; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 87 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(60);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1)
                {
                    信息 = "发送失败1...";
                    ECU零件号 = 信息;
                    return false;
                }
                if (!r2)
                {
                    信息 = "发送失败2...";
                    ECU零件号 = 信息;
                    return false;
                }

                zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);
                string[] hexValues = new string[5];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    else if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i == 0 || i > 2) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                var hexValuesStr = "";
                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    ECU零件号 = 信息;
                    return false;
                }


                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValuesStr += stringValue;
                }
                信息 = string.Join(",", datas);
                ECU零件号 = String.Join("", hexValues.ToList().GetRange(0, 4)).Trim() + "/" + hexValues[4];
                return true;

            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                ECU零件号 = 信息;
                throw;
            }
            return true;
        }
       
     
       
       
        [ExposedMethodAttribute("")]
        public bool 读NVM版本号(int 通道, out string NVM版本号, out int 字节长度, out string 信息)
        {
            NVM版本号 = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }//2E写
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 3; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 4C E8 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    NVM版本号 = 信息;
                    return false;
                }

                zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);
                //10 09  62 4C E8 56 30 30
                //21 2E 30 31 AA AA AA AA
                string[] hexValues = new string[6];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    else if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i == 0 || i > 3) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                var hexValuesStr = "";
                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    return false;
                }

                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValuesStr += stringValue;
                }
                信息 = string.Join(",", datas);
                NVM版本号 = hexValuesStr;
                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                return false;
            }

        }
        [ExposedMethodAttribute("")]
        public bool 读取产品供电电压(int 通道, out double 产品供电电压, out int 字节长度, out string 信息)
        {
            产品供电电压 = 0.0;
            字节长度 = 0;
            信息 = "";
            try
            {
                bool flag = !数据.初始化(通道, out ZLGCANHelper zLGCANHelper);
                if (flag)
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 300, 100.0);
                bool flag2 = false;
                bool flag3 = false;
                for (int i = 0; i < 3; i++)
                {
                    flag2 = zLGCANHelper.SentData(通道, 1889U, "03 22 B1 06 00 00 00 00", true, SendType.正常发送, Protocol.CAN, Frametype.标准帧, 1);
                    Thread.Sleep(60);
                    flag3 = zLGCANHelper.SentData(通道, 1889U, "30 08 14 00 00 00 00 00", true, SendType.正常发送, Protocol.CAN, Frametype.标准帧, 1);
                    bool flag4 = flag2 && flag3;
                    if (flag4)
                    {
                        break;
                    }
                }
                bool flag5 = !flag2;
                if (flag5)
                {
                    信息 = "发送失败1...";
                    产品供电电压 = -1.0;
                    return false;
                }
                bool flag6 = !flag3;
                if (flag6)
                {
                    信息 = "发送失败2...";
                    产品供电电压 = -2.0;
                    return false;
                }
                zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 3, 1500.0);
                string[] data = ZLGCanTool.GetData(zCAN_Receive_Datas);
                string[] array = new string[1];
                int num = 0;
                bool flag7 = false;
                foreach (string text in data)
                {
                    bool flag8 = text.Trim().StartsWith("10");
                    if (flag8)
                    {
                        flag7 = true;
                        for (int k = 0; k < text.Split(new char[] { ' ' }).Length; k++)
                        {
                            bool flag9 = k < 5 || k > 5;
                            if (!flag9)
                            {
                                array[num] = text.Split(new char[] { ' ' })[k];
                                num++;
                            }
                        }
                    }
                }
                字节长度 = array.Length;
                bool flag10 = flag7;
                if (flag10)
                {
                    int num2 = Convert.ToInt32(array[0], 16);
                    double num3 = (double)num2 / 10.0;
                    产品供电电压 = num3;
                    return false;
                }
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                产品供电电压 = -3.0;
                throw;
            }
            return true;
        }
        [ExposedMethodAttribute("")]
        public bool 读取MPU零件号(int 通道, out string MPU零件号, out int 字节长度, out string 信息)
        {
            MPU零件号 = "";
            字节长度 = 0;
            信息 = "";
            bool flag2;
            try
            {
                bool flag = !数据.初始化(通道, out ZLGCANHelper zLGCANHelper);
                if (flag)
                {
                    信息 = "启动can设备失败";
                    MPU零件号 = 信息;
                    flag2 = false;
                }
                else
                {
                    List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 300, 100.0);
                    bool flag3 = false;
                    bool flag4 = false;
                    for (int i = 0; i < 3; i++)
                    {
                        flag3 = zLGCANHelper.SentData(通道, 1889U, "03 22 B1 10 00 00 00 00", true, SendType.正常发送, Protocol.CAN, Frametype.标准帧, 1);
                        Thread.Sleep(60);
                        flag4 = zLGCANHelper.SentData(通道, 1889U, "30 08 14 00 00 00 00 00", true, SendType.正常发送, Protocol.CAN, Frametype.标准帧, 1);
                        bool flag5 = flag3 && flag4;
                        if (flag5)
                        {
                            break;
                        }
                    }
                    bool flag6 = !flag3 || !flag4;
                    if (flag6)
                    {
                        信息 = "发送失败...";
                        MPU零件号 = 信息;
                        flag2 = false;
                    }
                    else
                    {
                        zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 3, 1500.0);
                        string[] data = ZLGCanTool.GetData(zCAN_Receive_Datas);
                        string[] array = new string[8];
                        int num = 0;
                        bool flag7 = false;
                        bool flag8 = false;
                        foreach (string text in data)
                        {
                            bool flag9 = text.Trim().StartsWith("10");
                            if (flag9)
                            {
                                flag7 = true;
                                for (int k = 0; k < text.Split(new char[] { ' ' }).Length; k++)
                                {
                                    bool flag10 = k < 5 || k > 7;
                                    if (!flag10)
                                    {
                                        array[num] = text.Split(new char[] { ' ' })[k];
                                        num++;
                                    }
                                }
                            }
                            else
                            {
                                bool flag11 = text.Trim().StartsWith("21");
                                if (flag11)
                                {
                                    flag8 = true;
                                    for (int l = 0; l < text.Split(new char[] { ' ' }).Length; l++)
                                    {
                                        bool flag12 = l == 0 || l > 5;
                                        if (!flag12)
                                        {
                                            array[num] = text.Split(new char[] { ' ' })[l];
                                            num++;
                                        }
                                    }
                                }
                            }
                        }
                        字节长度 = array.Length;
                        string text2 = "";
                        bool flag13 = !flag7 || !flag8;
                        if (flag13)
                        {
                            信息 = string.Join("", data);
                            MPU零件号 = 信息;
                            flag2 = false;
                        }
                        else
                        {
                            foreach (string text3 in array)
                            {
                                int num2 = Convert.ToInt32(text3, 16);
                                string text4 = char.ConvertFromUtf32(num2);
                                text2 += text4;
                            }
                            信息 = string.Join(",", data);
                            MPU零件号 = string.Join("", array.ToList<string>().GetRange(0, 4)).Trim() + "/" + array[4];
                            flag2 = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                MPU零件号 = 信息;
                flag2 = false;
            }
            return flag2;
        }
        //[ExposedMethodAttribute("")]
        //public bool 读SOC软件版本号(int 通道, out string SOC软件版本号, out int 字节长度, out string 信息)
        //{
        //    SOC软件版本号 = "";
        //    字节长度 = 0;
        //    信息 = "";
        //    bool flag2;
        //    try
        //    {
        //        bool flag = !数据.初始化(通道, out ZLGCANHelper zLGCANHelper);
        //        if (flag)
        //        {
        //            信息 = "启动can设备失败";
        //            SOC软件版本号 = 信息;
        //            flag2 = false;
        //        }
        //        else
        //        {
        //            List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 300, 100.0);
        //            bool flag3 = false;
        //            bool flag4 = false;
        //            for (int i = 0; i < 3; i++)
        //            {
        //                flag3 = zLGCANHelper.SentData(通道, 1889U, "03 22 B1 0C 00 00 00 00", true, SendType.正常发送, Protocol.CAN, Frametype.标准帧, 1);
        //                Thread.Sleep(60);
        //                flag4 = zLGCANHelper.SentData(通道, 1889U, "30 08 14 00 00 00 00 00", true, SendType.正常发送, Protocol.CAN, Frametype.标准帧, 1);
        //                Thread.Sleep(100);
        //                bool flag5 = flag3 && flag4;
        //                if (flag5)
        //                {
        //                    break;
        //                }
        //            }
        //            bool flag6 = !flag3 || !flag4;
        //            if (flag6)
        //            {
        //                信息 = "发送失败...";
        //                SOC软件版本号 = 信息;
        //                flag2 = false;
        //            }
        //            else
        //            {
        //                zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 3, 1500.0);
        //                string[] data = ZLGCanTool.GetData(zCAN_Receive_Datas);
        //                string[] array = new string[15];
        //                int num = 0;
        //                bool flag7 = false;
        //                bool flag8 = false;
        //                bool flag9 = false;
        //                foreach (string text in data)
        //                {
        //                    bool flag10 = text.Trim().StartsWith("10");
        //                    if (flag10)
        //                    {
        //                        flag7 = true;
        //                        for (int k = 0; k < text.Split(new char[] { ' ' }).Length; k++)
        //                        {
        //                            bool flag11 = k < 5 || k > 7;
        //                            if (!flag11)
        //                            {
        //                                array[num] = text.Split(new char[] { ' ' })[k];
        //                                num++;
        //                            }
        //                        }
        //                    }
        //                    else
        //                    {
        //                        bool flag12 = text.Trim().StartsWith("21");
        //                        if (flag12)
        //                        {
        //                            flag8 = true;
        //                            for (int l = 0; l < text.Split(new char[] { ' ' }).Length; l++)
        //                            {
        //                                bool flag13 = l == 0 || l > 7;
        //                                if (!flag13)
        //                                {
        //                                    array[num] = text.Split(new char[] { ' ' })[l];
        //                                    num++;
        //                                }
        //                            }
        //                        }
        //                        else
        //                        {
        //                            bool flag14 = text.Trim().StartsWith("22");
        //                            if (flag14)
        //                            {
        //                                flag9 = true;
        //                                for (int m = 0; m < text.Split(new char[] { ' ' }).Length; m++)
        //                                {
        //                                    bool flag15 = m == 0 || m > 5;
        //                                    if (!flag15)
        //                                    {
        //                                        array[num] = text.Split(new char[] { ' ' })[m];
        //                                        num++;
        //                                    }
        //                                }
        //                            }
        //                        }
        //                    }
        //                }
        //                string text2 = "";
        //                bool flag16 = !flag7 || !flag8 || !flag9;
        //                if (flag16)
        //                {
        //                    信息 = string.Join("", data);
        //                    SOC软件版本号 = 信息;
        //                    flag2 = false;
        //                }
        //                else
        //                {
        //                    字节长度 = array.Length;
        //                    foreach (string text3 in array)
        //                    {
        //                        text2 += Convert.ToString(text3);
        //                    }
        //                    信息 = string.Join(",", data);
        //                    SOC软件版本号 = text2;
        //                    flag2 = true;
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        信息 = ex.Message;
        //        SOC软件版本号 = 信息;
        //        flag2 = false;
        //    }
        //    return flag2;
        //}
        [ExposedMethodAttribute("")]
        public bool 读电控单元引导加载软件参考号F183(int 通道, out string 软件参考号, out int 字节长度, out string 信息)
        {
            软件参考号 = "";
            字节长度 = 0;
            信息 = "";
            bool flag2;
            try
            {
                bool flag = !数据.初始化(通道, out ZLGCANHelper zLGCANHelper);
                if (flag)
                {
                    信息 = "启动can设备失败";
                    软件参考号 = 信息;
                    flag2 = false;
                }
                else
                {
                    List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 300, 100.0);
                    bool flag3 = false;
                    bool flag4 = false;
                    for (int i = 0; i < 3; i++)
                    {
                        flag3 = zLGCANHelper.SentData(通道, 1889U, "03 22 F1 83 00 00 00 00", true, SendType.正常发送, Protocol.CAN, Frametype.标准帧, 1);
                        Thread.Sleep(60);
                        flag4 = zLGCANHelper.SentData(通道, 1889U, "30 08 14 00 00 00 00 00", true, SendType.正常发送, Protocol.CAN, Frametype.标准帧, 1);
                        Thread.Sleep(100);
                        bool flag5 = flag3 && flag4;
                        if (flag5)
                        {
                            break;
                        }
                    }
                    bool flag6 = !flag3 || !flag4;
                    if (flag6)
                    {
                        信息 = "发送失败...";
                        软件参考号 = 信息;
                        flag2 = false;
                    }
                    else
                    {
                        zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 3, 1500.0);
                        string[] data = ZLGCanTool.GetData(zCAN_Receive_Datas);
                        string[] array = new string[6];
                        int num = 0;
                        bool flag7 = false;
                        bool flag8 = false;
                        foreach (string text in data)
                        {
                            bool flag9 = text.Trim().StartsWith("10");
                            if (flag9)
                            {
                                flag7 = true;
                                for (int k = 0; k < text.Split(new char[] { ' ' }).Length; k++)
                                {
                                    bool flag10 = k < 5 || k > 7;
                                    if (!flag10)
                                    {
                                        array[num] = text.Split(new char[] { ' ' })[k];
                                        num++;
                                    }
                                }
                            }
                            else
                            {
                                bool flag11 = text.Trim().StartsWith("21");
                                if (flag11)
                                {
                                    flag8 = true;
                                    for (int l = 0; l < text.Split(new char[] { ' ' }).Length; l++)
                                    {
                                        bool flag12 = l == 0 || l > 3;
                                        if (!flag12)
                                        {
                                            array[num] = text.Split(new char[] { ' ' })[l];
                                            num++;
                                        }
                                    }
                                }
                            }
                        }
                        bool flag13 = !flag7 || !flag8;
                        if (flag13)
                        {
                            信息 = string.Join("", data);
                            软件参考号 = 信息;
                            flag2 = false;
                        }
                        else
                        {
                            字节长度 = array.Length;
                            string text2 = "";
                            foreach (string text3 in array)
                            {
                                int num2 = Convert.ToInt32(text3, 16);
                                string text4 = char.ConvertFromUtf32(num2);
                                text2 += text4;
                            }
                            信息 = string.Join(",", data);
                            软件参考号 = text2;
                            flag2 = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                软件参考号 = 信息;
                flag2 = false;
            }
            return flag2;
        }




        //================================ 返回值：BCD模式 =========================================
        [ExposedMethodAttribute("")]
        public bool 读ECU零件号F187(int 通道, out string ECU零件号, out int 字节长度, out string 信息)
        {
            ECU零件号 = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 300, 100);//清空缓存
                bool r1 = false, r2 = false;
                for (int i = 0; i < 3; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 87 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(60);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1)
                {
                    信息 = "发送失败1...";
                    ECU零件号 = 信息;
                    return false;
                }
                if (!r2)
                {
                    信息 = "发送失败2...";
                    ECU零件号 = 信息;
                    return false;
                }

                zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                /*
                    10 08 62 F1 87 11 68 36
                    21 22 05 AA AA AA AA AA
                */

                string[] hexValues = new string[5];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    else if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i == 0 || i > 2) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValuesStr = "";
                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    ECU零件号 = 信息;
                    return false;
                }

                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValuesStr += stringValue;
                }
                信息 = string.Join(",", datas);
                ECU零件号 = String.Join("", hexValues.ToList().GetRange(0, 4)).Trim() + "/" + hexValues[4];
                return true;

            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                ECU零件号 = 信息;
                throw;
            }
        }
       
        [ExposedMethodAttribute("")]
        public bool 读ECU应用软件号F1A0(int 通道, out string ECU应用软件号, out int 字节长度, out string 信息)
        {
            ECU应用软件号 = "";
            字节长度 = 0;
            信息 = "";

            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 A0 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    ECU应用软件号 = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                /*
                    10 08 62 F1 A0 11 77 23
                    21 72 04 AA AA AA AA AA
                */

                string[] hexValues = new string[5];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 2) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;

                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    ECU应用软件号 = 信息;
                    return false;
                }

                信息 = string.Join(",", datas);
                ECU应用软件号 = String.Join("", hexValues);
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读ECU配置文件编号F1A9(int 通道, out string ECU配置文件编号, out int 字节长度, out string 信息)
        {
            ECU配置文件编号 = "";
            字节长度 = 0;
            信息 = "";

            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 A9 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    ECU配置文件编号 = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                /*
                    10 08 62 F1 A9 31 33 33
                    21 33 34 AA AA AA AA AA
                 */

                string[] hexValues = new string[5];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 2) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;

                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    ECU配置文件编号 = 信息;
                    return false;
                }

                信息 = string.Join(",", datas);
                ECU配置文件编号 = String.Join("", hexValues);
                return ok10;

            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读ECU编程过程文件编号F1AA(int 通道, out string ECU应用软件号, out int 字节长度, out string 信息)
        {
            ECU应用软件号 = "";
            字节长度 = 0;
            信息 = "";

            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 AA 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    ECU应用软件号 = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                /*
                    10 08 62 F1 AA 10 40 24
                    22 22 02 AA AA AA AA AA
                */

                string[] hexValues = new string[5];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 2) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;

                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    ECU应用软件号 = 信息;
                    return false;
                }

                信息 = string.Join(",", datas);
                ECU应用软件号 = String.Join("", hexValues);
                return ok10;

            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读ECU二级应用软件F1B5(int 通道, out string ECU二级应用软件, out int 字节长度, out string 信息)
        {
            ECU二级应用软件 = "";
            字节长度 = 0;
            信息 = "";

            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 B5 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    ECU二级应用软件 = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                /*
                    10 08 62 F1 B5 33 33 33
                    22 33 34 AA AA AA AA AA
                 */

                string[] hexValues = new string[5];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 2) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;

                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    ECU二级应用软件 = 信息;
                    return false;
                }

                信息 = string.Join(",", datas);
                ECU二级应用软件 = String.Join("", hexValues);
                return ok10;

            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读ECU三级应用软件号F1B6(int 通道, out string ECU三级应用软件号, out int 字节长度, out string 信息)
        {
            ECU三级应用软件号 = "";
            字节长度 = 0;
            信息 = "";

            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 B6 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    ECU三级应用软件号 = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                /*
                    10 08 62 F1 B6 11 68 25
                    22 71 AA AA AA AA AA AA
                 */

                string[] hexValues = new string[5];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 2) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;

                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    ECU三级应用软件号 = 信息;
                    return false;
                }

                信息 = string.Join(",", datas);
                ECU三级应用软件号 = String.Join("", hexValues);
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读ACCF1B7(int 通道, out string ACC, out int 字节长度, out string 信息)
        {
            ACC = "";
            字节长度 = 0;
            信息 = "";

            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 B7 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    ACC = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                /*
                    10 08 62 F1 B6 11 68 25
                    22 71 AA AA AA AA AA AA
                 */

                string[] hexValues = new string[5];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 2) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;

                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    ACC = 信息;
                    return false;
                }

                信息 = string.Join(",", datas);
                ACC = String.Join("", hexValues);
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }


        //================================ 返回值：HEX + ASCII 模式 =========================================

        [ExposedMethodAttribute("")]
        public bool 读配置可追溯字段F198(int 通道, out string 配置可追溯字段Hex, out string 配置可追溯字段Asc, out int 字节长度, out string 信息)
        {
            配置可追溯字段Hex = "";
            配置可追溯字段Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 98 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    配置可追溯字段Hex = 信息;
                    配置可追溯字段Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[14];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                bool ok22 = false;
                /*
                    10 0E 62 F1 98 31 33 33
                    21 33 33 33 33 33 33 33
                    22 39 AA AA AA AA AA AA
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("22"))
                    {
                        ok22 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 1) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10 || !ok21 || !ok22)
                {
                    信息 = string.Join("", datas);
                    配置可追溯字段Hex = 信息;
                    配置可追溯字段Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                配置可追溯字段Hex = string.Join("", hexValues);
                配置可追溯字段Asc = hexValues0;
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读ECUNCF参考编号F1A2(int 通道, out string ECUNCF参考编号Hex, out string ECUNCF参考编号Asc, out int 字节长度, out string 信息)
        {
            ECUNCF参考编号Hex = "";
            ECUNCF参考编号Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 A2 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    ECUNCF参考编号Hex = 信息;
                    ECUNCF参考编号Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[11];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                /*
                    10 0B 62 F1 A2 34 01 15
                    21 11 67 80 56 01 AA AA
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 5) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    ECUNCF参考编号Hex = 信息;
                    ECUNCF参考编号Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                ECUNCF参考编号Hex = string.Join("", hexValues);
                ECUNCF参考编号Asc = hexValues0;
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读ECU索引信息F1A5(int 通道, out string ECU索引信息Hex, out string ECU索引信息Asc, out int 字节长度, out string 信息)
        {
            ECU索引信息Hex = "";
            ECU索引信息Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 A5 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    ECU索引信息Hex = 信息;
                    ECU索引信息Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[3];
                int num = 0;
                bool ok10 = false;
                /*
                    06 62 F1 A5 00 00 00 AA
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("06"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 4 || i > 6) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10)
                {
                    信息 = string.Join("", datas);
                    ECU索引信息Hex = 信息;
                    ECU索引信息Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                ECU索引信息Hex = string.Join("", hexValues);
                ECU索引信息Asc = hexValues0;
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读车辆功能信息F1A8(int 通道, out string 车辆功能信息Hex, out string 车辆功能信息Asc, out int 字节长度, out string 信息)
        {
            车辆功能信息Hex = "";
            车辆功能信息Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 A8 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    车辆功能信息Hex = 信息;
                    车辆功能信息Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[20];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                bool ok22 = false;
                bool ok23 = false;
                /*
                    10 17 62 F1 A8 FF FF FF
                    21 FF FF FF FF FF FF FF
                    22 FF FF FF FF FF FF FF
                    23 FF FF FF AA AA AA AA
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("22"))
                    {
                        ok22 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("23"))
                    {
                        ok22 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 3) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10 || !ok21 || !ok22 || !ok23)
                {
                    信息 = string.Join("", datas);
                    车辆功能信息Hex = 信息;
                    车辆功能信息Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                车辆功能信息Hex = string.Join("", hexValues);
                车辆功能信息Asc = hexValues0;
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读SVIF数据F100(int 通道, out string SVIF数据Hex, out string SVIF数据Asc, out int 字节长度, out string 信息)
        {
            SVIF数据Hex = "";
            SVIF数据Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 00 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    SVIF数据Hex = 信息;
                    SVIF数据Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[6];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                /*
                    10 09 62 F1 00 FF FF FF
                    21 FF FF FF AA AA AA AA
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 3) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    SVIF数据Hex = 信息;
                    SVIF数据Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                SVIF数据Hex = string.Join("", hexValues);
                SVIF数据Asc = hexValues0;
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
       
        [ExposedMethodAttribute("")]
        public bool 读取LIN数据4CE7(int 通道, out string LIN数据Hex, out string LIN数据Asc, out int 字节长度, out string 信息)
        {
            LIN数据Hex = "";
            LIN数据Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 4C E7 00 AA AA AA", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    LIN数据Hex = 信息;
                    LIN数据Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[17];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                bool ok22 = false;
                /*
                    10 15 62 4C E7 01 FF FF ,
                    21 FF FF FF FF FF FF 02 ,
                    22 FF FF FF FF FF FF FF
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("22"))
                    {
                        ok22 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10 || !ok21 || !ok22)
                {
                    信息 = string.Join("", datas);
                    LIN数据Hex = 信息;
                    LIN数据Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                LIN数据Hex = string.Join("", hexValues).Substring(0, 8);  //只需要保证读取到前8位就可以了
                LIN数据Asc = hexValues0;
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读取MPU版本号B111(int 通道, out string MPU版本号Hex, out string MPU版本号Asc, out int 字节长度, out string 信息)
        {
            MPU版本号Hex = "";
            MPU版本号Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                //_ = zLGCANHelper.RecvData(通道, 0x769, 1000, 100);
                //bool OK = Can.解密(通道, out 信息, "62");
                //if (!OK)
                //{
                //    return false;
                //}
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 B1 11 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    MPU版本号Hex = 信息;
                    MPU版本号Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[8];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                /*
                    10 0B 62 B1 11 33 33 33
                    21 33 34 18 02 71 AA AA
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 5) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    MPU版本号Hex = 信息;
                    MPU版本号Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                MPU版本号Hex = string.Join("", hexValues);
                MPU版本号Asc = hexValues0;
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读NVM版本号4CE8(int 通道, out string NVM版本号Hex, out string NVM版本号Asc, out int 字节长度, out string 信息)
        {
            NVM版本号Hex = "";
            NVM版本号Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 4C E8 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    NVM版本号Hex = 信息;
                    NVM版本号Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[6];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                /*
                    10 09 62 4C E8 56 30 30
                    21 2E 30 31 AA AA AA AA
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 3) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    NVM版本号Hex = 信息;
                    NVM版本号Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                NVM版本号Hex = string.Join("", hexValues);
                NVM版本号Asc = hexValues0;
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读SOC软件版本号B10C(int 通道, out string SOC软件版本号Hex, out string SOC软件版本号Asc, out int 字节长度, out string 信息)
        {
            SOC软件版本号Hex = "";
            SOC软件版本号Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 1897U, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 1889U, "03 22 B1 0C 00 00 00 00", true, SendType.正常发送);
                    eLog.AddLog($"读SOC软件版本号B10C命令：03 22 B1 0C 00 00 00 00", eMsgType.Debug);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 1889U, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 1889U, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(100);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    SOC软件版本号Hex = 信息;
                    SOC软件版本号Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 1897U, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);
                eLog.AddLog($"读SOC软件版本号B10C命令：{string.Join(",", datas)}", eMsgType.Debug);
                string[] hexValues = new string[15];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                bool ok22 = false;
                /*
                    10 12 62 B1 0C 11 75 65
                    21 07 05 11 77 09 17 04
                    22 11 77 23 72 04 AA AA
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("22"))
                    {
                        ok22 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 5) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10 || !ok21 || !ok22)
                {
                    信息 = "返回数据不完整，返回数据" + string.Join("", datas);
                    SOC软件版本号Hex = 信息;
                    SOC软件版本号Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                SOC软件版本号Hex = string.Join("", hexValues);
                SOC软件版本号Asc = hexValues0;
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读ECU硬件版本号F191(int 通道, out string ECU硬件版本号Hex, out string ECU硬件版本号Asc, out int 字节长度, out string 信息)
        {
            ECU硬件版本号Hex = "";
            ECU硬件版本号Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false, r2 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 91 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    r2 = zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1 && r2)
                    {
                        break;
                    }
                }
                if (!r1 || !r2)
                {
                    信息 = "发送失败...";
                    ECU硬件版本号Hex = 信息;
                    ECU硬件版本号Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[5];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                /*
                    10 08 62 F1 91 11 79 65
                    21 81 03 AA AA AA AA AA
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 2) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10 || !ok21)
                {
                    信息 = string.Join("", datas);
                    ECU硬件版本号Hex = 信息;
                    ECU硬件版本号Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                ECU硬件版本号Hex = string.Join("", hexValues);
                ECU硬件版本号Asc = hexValues0;
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }


        //=================================== 2024-09-27 ELO指令更新，以下方法为对应更新的内容 ==========================================
       
        [ExposedMethodAttribute("")]
        public bool 读EOL配置版本号B10A(int 通道, out string EOL配置版本号Hex, out string EOL配置版本号Asc, out int 字节长度, out string 信息)
        {
            EOL配置版本号Hex = "";
            EOL配置版本号Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 B1 0A 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    if (r1)
                    {
                        break;
                    }
                }
                if (!r1)
                {
                    信息 = "发送失败...";
                    EOL配置版本号Hex = 信息;
                    EOL配置版本号Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[3];
                int num = 0;
                bool ok10 = false;
                /*
                    06 62 B1 0A FF FF FF AA
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("06"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 4 || i > 6) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10)
                {
                    信息 = string.Join("", datas);
                    EOL配置版本号Hex = 信息;
                    EOL配置版本号Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                EOL配置版本号Hex = string.Join("", hexValues);
                EOL配置版本号Asc = hexValues0;
                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
      
        [ExposedMethodAttribute("")]
        public bool 读NIF工厂数据F120(int 通道, out string NIF工厂数据Hex, out string NIF工厂数据Asc, out int 字节长度, out string 信息)
        {
            NIF工厂数据Hex = "";
            NIF工厂数据Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 20 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1)
                    {
                        break;
                    }
                }
                if (!r1)
                {
                    信息 = "发送失败...";
                    NIF工厂数据Hex = 信息;
                    NIF工厂数据Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[16];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                bool ok22 = false;
                /*
                    10 13 62 F1 20 11 79 65
                    21 81 03 AA AA AA AA AA
                    22 00 00 00 00 FF FF AA
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("22"))
                    {
                        ok22 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 6) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10 || !ok21 || !ok22)
                {
                    信息 = string.Join("", datas);
                    NIF工厂数据Hex = 信息;
                    NIF工厂数据Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                NIF工厂数据Hex = string.Join("", hexValues);
                NIF工厂数据Asc = hexValues0;

                return ok10 && ok21 && ok22;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }
        [ExposedMethodAttribute("")]
        public bool 读NIF当前数据F121(int 通道, out string NIF当前数据Hex, out string NIF当前数据Asc, out int 字节长度, out string 信息)
        {
            NIF当前数据Hex = "";
            NIF当前数据Asc = "";
            字节长度 = 0;
            信息 = "";
            try
            {
                if (!数据.初始化(通道, out ZLGCANHelper zLGCANHelper))
                {
                    信息 = "启动can设备失败";
                    return false;
                }
                _ = zLGCANHelper.RecvData(通道, 0x769, 300, 100);
                Thread.Sleep(50);
                bool r1 = false;
                for (int i = 0; i < 5; i++)
                {
                    r1 = zLGCANHelper.SentData(通道, 0x761, "03 22 F1 21 00 00 00 00", true, SendType.正常发送);
                    Thread.Sleep(50);
                    zLGCANHelper.SentData(通道, 0x761, "30 08 14 00 00 00 00 00", true, SendType.正常发送);
                    if (r1)
                    {
                        break;
                    }
                }
                if (!r1)
                {
                    信息 = "发送失败...";
                    NIF当前数据Hex = 信息;
                    NIF当前数据Asc = 信息;
                    return false;
                }
                List<ZCAN_Receive_Data> zCAN_Receive_Datas = zLGCANHelper.RecvData(通道, 0x769, 3, 1500);
                string[] datas = ZLGCanTool.GetData(zCAN_Receive_Datas);

                string[] hexValues = new string[16];
                int num = 0;
                bool ok10 = false;
                bool ok21 = false;
                bool ok22 = false;
                /*
                    10 13 62 F1 21 11 79 65
                    21 81 03 AA AA AA AA AA
                    22 00 00 00 00 FF FF AA
                */
                foreach (string s in datas)
                {
                    if (s.Trim().StartsWith("10"))
                    {
                        ok10 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 5 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("21"))
                    {
                        ok21 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 7) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                    if (s.Trim().StartsWith("22"))
                    {
                        ok22 = true;
                        for (int i = 0; i < s.Split(' ').Length; i++)
                        {
                            if (i < 1 || i > 6) continue;
                            hexValues[num] = s.Split(' ')[i];
                            num++;
                        }
                    }
                }
                字节长度 = hexValues.Length;
                var hexValues0 = "";
                if (!ok10 || !ok21 || !ok22)
                {
                    信息 = string.Join("", datas);
                    NIF当前数据Hex = 信息;
                    NIF当前数据Asc = 信息;
                    return false;
                }
                foreach (String hex in hexValues)
                {
                    int value = Convert.ToInt32(hex, 16);
                    string stringValue = Char.ConvertFromUtf32(value);
                    hexValues0 += stringValue;
                }
                信息 = string.Join(",", datas);
                NIF当前数据Hex = string.Join("", hexValues);
                NIF当前数据Asc = hexValues0;

                return ok10;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                throw;
            }
        }


        private static string HexToAsciiExtended(string hex)
        {
            if (hex.Length % 2 != 0)
                throw new ArgumentException("十六进制字符串长度必须是偶数", nameof(hex));

            StringBuilder asciiStringBuilder = new StringBuilder();
            for (int i = 0; i < hex.Length; i += 2)
            {
                string byteAsString = hex.Substring(i, 2);
                asciiStringBuilder.Append((char)Convert.ToByte(byteAsString, 16));
            }

            return asciiStringBuilder.ToString();
        }
    }
}